package com.example.bms.storehouse.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.example.bms.storehouse.entity.ProviderEntity;
import com.example.bms.storehouse.service.ProviderService;
import com.example.common.utils.PageUtils;
import com.example.common.utils.R;



/**
 * 
 *
 * @author Jiang
 * @email 337262603@qq.com
 * @date 2022-01-29 23:13:47
 */
@RestController
@RequestMapping("storehouse/provider")
@CrossOrigin
public class  ProviderController {
    @Autowired
    private ProviderService providerService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("storehouse:provider:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = providerService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{pid}")
    //@RequiresPermissions("storehouse:provider:info")
    public R info(@PathVariable("pid") Integer pid){
		ProviderEntity provider = providerService.getById(pid);
        return R.ok().put("provider", provider);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("storehouse:provider:save")
    public R save(@RequestBody ProviderEntity provider){
		providerService.save(provider);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("storehouse:provider:update")
    public R update(@RequestBody ProviderEntity provider){
		providerService.updateById(provider);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("storehouse:provider:delete")
    public R delete(@RequestBody Integer[] pids){
		providerService.removeByIds(Arrays.asList(pids));
        return R.ok();
    }

}
